list-[id].vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <!-- 头部 -->
  3. <templateHead></templateHead>
  4. <!-- 菜单 -->
  5. <templateMenu></templateMenu>
  6. <!-- 内容 -->
  7. <div v-for="(item,index) in templateData" :key="index">
  8. <!--广告组件-->
  9. <div v-if="item.sectorName=='adSector'">
  10. <templateAd :skinId="skinId" :adData="adData" :adTag="item.ad.ad_tag" ></templateAd>
  11. </div>
  12. <!--列表组件-->
  13. <div v-if="item.sectorName=='fixedListSector'">
  14. <templateList :skinId="skinId" :templateData="item.componentList" :routeId="routeId" :pageData="pageData" :newsList="newsList"></templateList>
  15. </div>
  16. </div>
  17. <!-- 底部 -->
  18. <templateFoot></templateFoot>
  19. </template>
  20. <script setup>
  21. //0.加载全局模板组件 start---------------------------------------->
  22. //0.1全局通栏
  23. import templateHead from '@/components/template/sector/head/1200x200/1.vue'
  24. import templateMenu from '@/components/template/sector/menu/1200x130/1.vue'
  25. import templateFoot from '@/components/template/sector/foot/1200x580/1.vue'
  26. //0.2局部通栏
  27. //0.2.1广告组件
  28. import templateAd from '@/components/template/sector/body/ad/1200x90/1.vue'
  29. //0.2.2列表组件
  30. import templateList from '@/components/template/sector/body/list/list/1200x1220/1.vue'
  31. //0.加载全局模板组件 end---------------------------------------->
  32. //1.获得基本信息单元 start---------------------------------------->
  33. //1.1获得页面依赖
  34. import { ref, onMounted } from 'vue';
  35. //1.2使用url查询导航池id
  36. const targetSegment = getRoutePath(1);//当前页面的url路径 这是第一层 所以获得域名后面的第一层url
  37. const routeId = ref("");//当前url路径代表的cid
  38. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  39. method: 'GET',
  40. query: {
  41. 'pinyin': targetSegment,
  42. },
  43. });
  44. if (getRouteId.code == 200) {
  45. routeId.value = getRouteId.data.category_id
  46. }
  47. //1.3获得pinia源
  48. import { useTemplateBaseStore } from '@/stores/templateBase'
  49. const templateBaseStore = useTemplateBaseStore()
  50. //1.4获得该页的皮肤id - 在每个组件中也是同样的获得方法
  51. const skinId = ref("")
  52. const websiteId = ref("")
  53. //1.5获得站点基本信息
  54. const responseStatus = await requestDataPromise('/web/getWebsiteAllinfo', {
  55. method: 'GET',
  56. query: {
  57. 'link_textnum':24,
  58. 'link_imgnum':18,
  59. 'link_footnum':4
  60. },
  61. });
  62. if (responseStatus.code == 200) {
  63. //1.6.1设置站点基本信息
  64. templateBaseStore.setWebSiteInfo(responseStatus.data)
  65. websiteId.value = responseStatus.data.website_head.id;//获得网站id
  66. //1.6.2设置皮肤id
  67. skinId.value = templateBaseStore.webSiteInfo.website_foot.foot_info.template_id;
  68. }
  69. //1.6.seo
  70. const setData = await requestDataPromise('/web/getWebsiteCategoryHead', {
  71. method: 'GET',
  72. query: {
  73. 'catid': routeId.value
  74. },
  75. });
  76. let seoTitle = setData.data.seo_title;
  77. let seoDescription = setData.data.seo_description;
  78. let seoKeywords = setData.data.seo_keywords;
  79. let seoSuffix = setData.data.suffix;
  80. let seoName = setData.data.website_name;
  81. useSeoMeta({
  82. title: seoTitle + "_" + seoSuffix,
  83. meta: [
  84. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  85. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
  86. ]
  87. });
  88. //1.获得基本信息单元 end---------------------------------------->
  89. //2.页面数据 start---------------------------------------->
  90. //2.1获得页面模板数据
  91. const response = await requestDataPromise('/client/indexData', {
  92. method: 'POST',
  93. body: {
  94. 'website_id':websiteId.value,
  95. 'getpage':'index'
  96. },
  97. });
  98. //页面模板数据
  99. const templateData = response.data.template.list;
  100. console.log(templateData)
  101. //2.2广告数据
  102. const adData = ref([]);
  103. adData.value.push(response.data.ad.top)
  104. for(let item of response.data.ad.list){
  105. adData.value.push(item)
  106. }
  107. templateBaseStore.setAdList(adData.value)
  108. //2.3分页数据
  109. const route = useRoute();
  110. let pageNum = ref(1); //当前页码
  111. pageNum.value = parseInt(route.params.id);//路由中传递的分页页码
  112. let total = ref(0); //总条数
  113. let pageSize = ref(20); //每页条数
  114. //3.1新闻列表数据
  115. const newsList = ref([]);
  116. let newslists = async () => {
  117. const listData = await requestDataPromise('/web/getWebsiteArticleList', {
  118. method: 'GET',
  119. query: {
  120. 'page': pageNum.value,
  121. 'pageSize': pageSize.value,
  122. 'catid': routeId.value
  123. },
  124. });
  125. console.log(listData)
  126. if (listData.code == 200) {
  127. newsList.value = listData.data.rows;
  128. pageData.value.total = listData.data.count;
  129. }
  130. }
  131. newslists();
  132. let pageData = ref({
  133. "pageNum": pageNum.value,
  134. "pageSize": pageSize.value,
  135. "total": total.value
  136. });
  137. //2.页面数据 end---------------------------------------->
  138. </script>
  139. <style lang="less" scoped>
  140. @import url('@/assets/css/list.less');
  141. </style>